/**
 * User: LongDH
 * Date: 5/25/11
 * Time: 3:02 PM
 */
jQuery(document).ready(function ($) {
	
    var dates = $('#wv-startdate, #wv-enddate').datepicker({
        changeMonth: true,
        changeYear: true,
        showOtherMonths: true,
        selectOtherMonths: true,
        onSelect: function(selectedDate) {
            var option = this.id == "wv-startdate" ? "minDate" : "maxDate",
                    instance = $(this).data("datepicker"),
                    date = $.datepicker.parseDate(
                            instance.settings.dateFormat ||
                                    $.datepicker._defaults.dateFormat,
                            selectedDate, instance.settings);
            dates.not(this).datepicker("option", option, date);
        },
		onClose: function(){
			$(this).focus();
		}
    });

	$('.wv-coupon-metabox input').each(function(){
		if ($(this).val() == '') {
			$(this).siblings('.prompt-text').css('visibility', '');
		}
	});

	$('.wv-coupon-metabox .prompt-text').click(function(){
		$(this).css('visibility', 'hidden').siblings('input').focus();
	});
	
	$('.wv-coupon-metabox input').blur(function(){
		if (this.value == '')
			$(this).siblings('.prompt-text').css('visibility', '');
	}).focus(function(){
		$(this).siblings('.prompt-text').css('visibility', 'hidden');
	}).keydown(function(e){
		$(this).siblings('.prompt-text').css('visibility', 'hidden');
		$(this).unbind(e);
	});

})